﻿using Ewk.Configuration;
using Ewk.Math.Algebra.Algorithms.Matrices;
using Ewk.Math.Algebra.Factories;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.Math.Algebra.UnitTests.Factories
{
    [TestClass]
    public class UnityContainerSetupTests
    {
        [TestInitialize]
        public void MyTestInitialize()
        {
            UnityContainerSetup.Initialize();
        }

        [TestMethod]
        public void When_the_Resolve_method_on_UnityDependencyContainer_is_called_with_IRankComputer_and_the_requested_type_has_not_been_registered_it_returns_an_instance_of_the_default_type()
        {
            var requestedType = typeof(IRankComputer<double>);

            var actualInstance = DependencyConfiguration.DependencyResolver.Resolve<IRankComputer<double>>();

            Assert.IsNotNull(actualInstance);
            Assert.IsInstanceOfType(actualInstance, requestedType);
        }

        [TestMethod]
        public void When_the_Resolve_method_on_UnityDependencyContainer_is_called_with_IDeterminantComputer_and_the_requested_type_has_not_been_registered_it_returns_an_instance_of_the_default_type()
        {
            var requestedType = typeof(IDeterminantComputer<double>);

            var actualInstance = DependencyConfiguration.DependencyResolver.Resolve<IDeterminantComputer<double>>();

            Assert.IsNotNull(actualInstance);
            Assert.IsInstanceOfType(actualInstance, requestedType);
        }

        [TestMethod]
        public void When_the_Resolve_method_on_UnityDependencyContainer_is_called_with_IAdjugateComputer_and_the_requested_type_has_not_been_registered_it_returns_an_instance_of_the_default_type()
        {
            var requestedType = typeof(IAdjugateComputer<double>);

            var actualInstance = DependencyConfiguration.DependencyResolver.Resolve<IAdjugateComputer<double>>();

            Assert.IsNotNull(actualInstance);
            Assert.IsInstanceOfType(actualInstance, requestedType);
        }

        [TestMethod]
        public void When_the_Resolve_method_on_UnityDependencyContainer_is_called_with_IInverseComputer_and_the_requested_type_has_not_been_registered_it_returns_an_instance_of_the_default_type()
        {
            var requestedType = typeof(IInverseComputer<double>);

            var actualInstance = DependencyConfiguration.DependencyResolver.Resolve<IInverseComputer<double>>();

            Assert.IsNotNull(actualInstance);
            Assert.IsInstanceOfType(actualInstance, requestedType);
        }
    }
}
